import 'package:appflutterhomeschool/api/api_service.dart';
import 'package:appflutterhomeschool/api/dio_utils.dart';
import 'package:appflutterhomeschool/model/system_questions_model.dart';
import 'package:flutter/material.dart';

class AnswerSheetViewModel extends ChangeNotifier {
  BuildContext me;
  String id;
  List<SystemQuestionsModel> systemQuestions;

  AnswerSheetViewModel(this.me, this.id);

  initView() {
    Dio2Utils.getInstance()
        .post(ApiService.getSystemQuestions, {"student_homework_id": id},
            (successCallBack) {
      systemQuestions = [];
      Map dataMap = successCallBack["data"];
      if (dataMap == null) {
        return;
      }
      List listJson = dataMap["system_questions"];

      if (listJson.length < 0) {
        return;
      }
      listJson.forEach((element) {
        systemQuestions.add(SystemQuestionsModel.fromJson(element));
      });
      notifyListeners();
    }, (errorCallBack) {});
  }
}
